﻿using System.Collections.Generic;
using System.Configuration;
using Mollie.iDEAL;
using SuperSimpleWebshop.Common;
using SuperSimpleWebshop.Domain;
using SuperSimpleWebshop.Domain.Interfaces;

namespace SuperSimpleWebshop.Payment.Mollie
{
    public class MolliePaymentProvider : IPaymentProvider
    {
        #region IPaymentProvider Members
        public string GetName()
        {
            return "Mollie";
        }

        public PaymentParameterRenderMethod GetParameterRenderMethod()
        {
            return PaymentParameterRenderMethod.QueryString;
        }

        public List<PaymentProviderMethod> GetAllPaymentMethods(string name)
        {
            var helper = new PaymentConfigHelper(name);

            var paymentMethods = helper.PaymentProviderMethods;

            IdealBanks banks = new IdealBanks(helper.Settings["partnerId"], helper.TestModeEnabled);

            foreach (var bank in banks.Banks)
            {
                int paymentImageId = 0;

                int.TryParse(umbraco.library.GetDictionaryItem(bank.Name + "LogoId"), out paymentImageId);

                paymentMethods.Add(new PaymentProviderMethod
                {
                     Id = bank.Id,
                        Description = bank.Name,
                        Name = bank.Name,
                        ProviderName = GetName(),
                        ProviderNodeName = GetName(),
                        Title = bank.Name,
                        ImageId = paymentImageId
                });
            }

            return paymentMethods;
        }
        #endregion
    }
}
